<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/12/12
  Time: 11:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>Title</title>
    <jsp:include page="${pageContext.request.contextPath}/common/common.jsp" />

    <script>

        function searcha() {
            //返回表格的 Options。
            var opts = $("#usertb").bootstrapTable("getOptions") ;
            var limit = opts.pageSize ;
            var offset = (opts.pageNumber-1) * limit;
            var username = $("#username").val() ;
            $.post("${pageContext.request.contextPath}/user/querySearch",{'username':username,'limit':limit,'offset':offset},function (data) {
                // var mydata = eval("("+data+")") ;
                //重新绑定表格数据
                $("#usertb").bootstrapTable('load',data) ;
                var elems = Array.prototype.slice.call(document.querySelectorAll('.abc'));
                elems.forEach(function(html) {
                    var switchery = new Switchery(html);
                });
            })
        }
        //初始化
        $(function () {

            //出始化状态按钮
            var elem = document.getElementById("state") ;
            var init = new Switchery(elem);
            //给状态按钮增加事件
            $("#state").val(1);
            elem.onchange = function() {
                //给name= state的checkbx设置value值
                var flag = this.checked ;
                if (flag){
                    $("#state").val(1);
                }
                else{
                    $("#state").val(0);
                }
            };
             //启用校验
            $('#userform').bootstrapValidator({
                message: 'This value is not valid',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    workname: {
                        message: 'The username is not valid',
                        validators: {
                            notEmpty: {
                                message: '用户名不能为空！'
                            },
                            stringLength: {
                                min: 6,
                                max: 30,
                                message: '必须是6-30个字符'
                            },
                            regexp: {
                                regexp: /^[a-zA-Z0-9_\.]+$/,
                                message: '字母或者数字开头'
                            }
                        }
                    },
                    pwd: {
                        message: '',
                        validators: {
                            notEmpty: {
                                message: '密码不能为空！'
                            }
                        }
                    },
                    confirmpwd: {
                        message: '',
                        validators: {
                            notEmpty: {
                                message: '确认密码不能为空！'
                            },
                            identical: {
                                field: 'pwd',
                                message: '两次密码不一致'
                            }
                        }

                    },
                    phone: {
                        validators: {
                            notEmpty: {
                                message: '手机号码不能为空！'
                            },
                            regexp: {
                                regexp: /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/,
                                message: '请填写正确的手机号码'
                            }
                        }
                    }
                }
            })
            <!--时间日历-->
            $('#datetimepicker1').datetimepicker({
                format: 'YYYY-MM-DD',
                locale: moment.locale('zh-cn')
            });
            $('#datetimepicker2').datetimepicker({
                format: 'YYYY-MM-DD',
                locale: moment.locale('zh-cn')
            });
            $("#usertb").bootstrapTable({
                onLoadSuccess:function(data){
                    var elems = Array.prototype.slice.call(document.querySelectorAll('.abc'));
                    elems.forEach(function(html) {
                        var switchery = new Switchery(html);
                    });
                },
                url:'${pageContext.request.contextPath}/user/querySearch',
                pageSize:2,
                pageList:[2,4,8,16],
                height:380,
                pageNumber:1,
                //启用分页，但是默认情况下，是客户端分页的
                pagination:true,
                // //启用服务器端分页
                sidePagination:'server',
                // //设置 true 将禁止多选。
                singleSelect:false,
                queryParams:function(params){
                    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                        limit: params.limit,  //页面大小
                        offset: params.offset, //页码
                        username:$("#username").val()
                    };
                    return temp;
                },
                columns:[{
                        checkbox:true
                     },
                    {
                        field:'uid',
                        title:'编号'
                    },
                    {
                        field:'uname',
                        title:'名称'
                    },
                    {
                        field:'sex',
                        title:'性别'
                    },
                    {
                        field:'borndate',
                        title:'生日'
                    },
                    {
                        field:'phone',
                        title:'联系电话'
                    },
                    {
                        field:'state',
                        title:'状态',
                        formatter:function(a,b,c) {
                            if (b.state==1){
                                return "<input disabled checked type='checkbox' class='abc js-switch'/>" ;
                            }
                            else{
                                return "<input disabled type='checkbox' class='abc js-switch'/>" ;
                            }
                        }
                    },
                    {
                        field:'address',
                        title:'住址'
                    },
                    {
                        title:'操作',
                        formatter:function(value,row,index){
                            return "<button class='btn  btn-primary' onclick='tofenpei("+row.uid+")'><span class='glyphicon glyphicon-edit'></span>&nbsp;分配角色</button>&nbsp;&nbsp;<button class='btn  btn-primary' onclick='toxiugai(("+index+"))'><span class='glyphicon glyphicon-pencil'></span>&nbsp;修改</button>"
                        }
                    },
                ]
            }) ;
        }) ;

        var addStr = " <form class=\"form-horizontal\" id=\"userform\"  method=\"post\" role=\"form\">\n" +
            "                        <input type=\"hidden\" name=\"pn\">\n" +
            "                        <div class=\"form-group\">\n" +
            "                            <label class=\"col-sm-4 text-right\" for=\"username\">用户名</label>\n" +
            "                            <div class=\"col-sm-6\">\n" +
            "                                <input type=\"text\" class=\"form-control\" name=\"uname\"  placeholder=\"用户名\" />\n" +
            "                            </div>\n" +
            "                        </div>\n" +
            "                        <div class=\"form-group\">\n" +
            "                            <label for=\"upwd\" class=\"col-sm-4 text-right\">密码</label>\n" +
            "                            <div class=\"col-sm-6\">\n" +
            "                                <input type=\"password\" class=\"form-control\" name=\"upwd\"  />\n" +
            "                            </div>\n" +
            "                        </div>\n" +
            "                        <div class=\"form-group\">\n" +
            "                            <label for=\"confirmpwd\" class=\"col-sm-4 text-right\">确认密码</label>\n" +
            "                            <div class=\"col-sm-6\">\n" +
            "                                <input type=\"password\" class=\"form-control\" name=\"confirmpwd\"  />\n" +
            "                            </div>\n" +
            "                        </div>\n" +
            "                        <div class=\"form-group\">\n" +
            "                            <label for=\"state\" class=\"col-sm-4 text-right\">状态</label>\n" +
            "                            <div class=\"col-sm-6\">\n" +
            "                                <input id=\"state\" value=\"1\" type=\"checkbox\" class=\"js-switch\" checked name=\"state\"/>\n" +
            "                            </div>\n" +
            "                        </div>\n" +
            "                        <div class=\"form-group\">\n" +
            "                            <label for=\"workname\" class=\"col-sm-4 text-right\">workName</label>\n" +
            "                            <div class=\"col-sm-6\">\n" +
            "                                <input type=\"text\" class=\"form-control\" name=\"workName\"  />\n" +
            "                            </div>\n" +
            "                        </div>\n" +
            "                        <div class=\"form-group\">\n" +
            "                            <label for=\"sex\" class=\"col-sm-4 text-right\">性别</label>\n" +
            "                            <div class=\"col-sm-6\">\n" +
            "                                <div class=\"radio-inline\" style=\"margin-top: -8px\">\n" +
            "                                    <input type=\"radio\" name=\"sex\" value=\"男\" style=\"margin-top: 2px\">\n" +
            "                                    男\n" +
            "                                </div>\n" +
            "    \n" +
            "                                <div class=\"radio-inline\" style=\"margin-top: -8px\">\n" +
            "                                    <input type=\"radio\" name=\"sex\" value=\"女\" style=\"margin-top: 2px\"> 女\n" +
            "                                </div>\n" +
            "                            </div>\n" +
            "                        </div>\n" +
            "                        <div class=\"form-group\">\n" +
            "                            <label for=\"phone\" class=\"col-sm-4 text-right\">手机</label>\n" +
            "                            <div class=\"col-sm-6\">\n" +
            "                                <input type=\"text\" class=\"form-control\" name=\"phone\"  />\n" +
            "                            </div>\n" +
            "                        </div>\n" +
            "                        <div class=\"form-group\">\n" +
            "                            <label for=\"borndate\" class=\"col-sm-4 text-right\">生日</label>\n" +
            "                            <div class=\"col-sm-6\">\n" +
            "                                <div class=\"input-group\" id=\"datetimepicker1\">\n" +
            "                                    <input name=\"borndate\" type='text' class=\"form-control\" />\n" +
            "                                    <span class=\"input-group-addon\"><span class=\"glyphicon glyphicon-calendar\"></span></span>\n" +
            "                                </div>\n" +
            "                            </div>\n" +
            "                        </div>\n" +
            "                        <div class=\"form-group\">\n" +
            "                            <label for=\"idCard\" class=\"col-sm-4 text-right\">身份证</label>\n" +
            "                            <div class=\"col-sm-6\">\n" +
            "                                <input type=\"text\" id=\"idCard\" class=\"form-control\" name=\"idCard\"  />\n" +
            "                            </div>\n" +
            "                        </div>\n" +
            "                        <div class=\"form-group\">\n" +
            "                            <label for=\"address\" class=\"col-sm-4 text-right\">籍贯</label>\n" +
            "                            <div class=\"col-sm-6\">\n" +
            "                                <input type=\"text\" class=\"form-control\" name=\"address\" id=\"address\">\n" +
            "                            </div>\n" +
            "                        </div>\n" +
            "                    </form>";
        //打开增加的对话框
        function toadd() {
            $("#addmodal").modal("show") ;
            $("#addmodal").on("shown.bs.modal",function () {
                $("#addModel").html(addStr);
                <!--时间日历-->
                $('#datetimepicker1').datetimepicker({
                    format: 'YYYY-MM-DD',
                    locale: moment.locale('zh-cn')
                });
                //出始化状态按钮
                var elem = document.getElementById("state") ;
                var init = new Switchery(elem);
                // $("#state").val(1);
                //给状态按钮增加事件
                elem.onchange = function() {
                    //给name= state的checkbx设置value值
                    var flag = this.checked ;
                    if (flag){
                        $("#state").val(1);
                    }
                    else{
                        $("#state").val(0);
                    }
                };
                $('#userform').bootstrapValidator({
                    message: 'This value is not valid',
                    feedbackIcons: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    },
                    fields: {
                        workname: {
                            message: 'The username is not valid',
                            validators: {
                                notEmpty: {
                                    message: '用户名不能为空！'
                                },
                                stringLength: {
                                    min: 6,
                                    max: 30,
                                    message: '必须是6-30个字符'
                                },
                                regexp: {
                                    regexp: /^[a-zA-Z0-9_\.]+$/,
                                    message: '字母或者数字开头'
                                }
                            }
                        },
                        pwd: {
                            message: '',
                            validators: {
                                notEmpty: {
                                    message: '密码不能为空！'
                                }
                            }
                        },
                        confirmpwd: {
                            message: '',
                            validators: {
                                notEmpty: {
                                    message: '确认密码不能为空！'
                                },
                                identical: {
                                    field: 'pwd',
                                    message: '两次密码不一致'
                                }
                            }

                        },
                        phone: {
                            validators: {
                                notEmpty: {
                                    message: '手机号码不能为空！'
                                },
                                regexp: {
                                    regexp: /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/,
                                    message: '请填写正确的手机号码'
                                }
                            }
                        }
                    }
                });
            });
        }
        //增加用户
        function doadd() {
            //启用较验
            $('#userform').data('bootstrapValidator').validate();
            //验证是否通过true/false
            var flag = $('#userform').data('bootstrapValidator').isValid();
            if (flag) {
                //绑定当前页开始
                var options = $("#usertb").bootstrapTable('getOptions');
                //得到当前页
                var pn = options.pageNumber;
                $("input[name='pn']").val(pn);
                //序列化表单
                var formStr = $('#userform').serialize();
                //处理表单控件的中文乱码
                params = decodeURIComponent(formStr, true);

                var state = $("#state").val();

                params = params + "&state=" + state

                // alert(params);
                $.ajax({
                    'type': 'post',
                    'url': '${pageContext.request.contextPath}/user/save',
                    'data': params,
                    success: function (data) {
                        //关闭对话框
                        $("#addmodal").modal('hide');
                        //提示增加成功
                        swal("提示信息", "增加成功!", "success");
                        //重新加载表格
                        $("#usertb").bootstrapTable('load', data);
                        var elems = Array.prototype.slice.call(document.querySelectorAll('.abc'));
                        elems.forEach(function(html) {
                            var switchery = new Switchery(html);
                        });
                    }
                })
            }
        }

        //修改用户
        function toxiugai(index) {
            //取消所有选择
            $("#usertb").bootstrapTable("uncheckAll");
            //选中要修改的行
            $("#usertb").bootstrapTable("check", index);
            // $("#md1").html(s3) ;
            //得到所选行的数据
            var row = $("#usertb").bootstrapTable("getSelections")[0];
            //绑定主键u
            $("input[name='uid']").val(row.uid);
            //绑定当前页开始
            var options = $("#usertb").bootstrapTable('getOptions') ;
            //得到当前页
            var pn = options.pageNumber ;

            //绑定当前页
            $("input[name='pn']").val(pn) ;
            $("input[name='uname']").val(row.uname);
            $("input[name='upwd']").val(row.upwd);
            $("input[name='workName']").val(row.workName);
            $("input[name='phone']").val(row.phone);
            $("input[name='address']").val(row.address);
            $("input[name='borndate']").val(row.borndate);
            $("input[name='idCard']").val(row.idCard);
            var state = row.state  ;
            if (state==1){
                $("#state1c").html("<input value='1' checked id=\"state1\" type=\"checkbox\" class=\"js-switch\" name=\"state\"  />") ;
            }
            else{
                $("#state1c").html("<input value='0' id=\"state1\" type=\"checkbox\" class=\"js-switch\" name=\"state\"  />") ;
            }

            if (row.uid==1){
                $("#state1c").html("<input value='"+state+"'  disabled checked id=\"state1\" type=\"checkbox\" class=\"js-switch\" name=\"state\"  />") ;
            }

            var elem1 = document.getElementById("state1") ;
            var init = new Switchery(elem1);
            //给状态按钮增加事件
            elem1.onchange = function() {
                //给name= state的checkbx设置value值
                var flag = this.checked ;
                if (flag){
                    $("#state1").val(1);
                }
                else{
                    $("#state1").val(0);
                }
            };
            // $("[name='sex'][value='" + row.sex + "']").attr("checked", "checked");
            var sex = row.sex ;

            if (sex =='男'){
                $("#a").html("<input type=\"radio\" checked=\"checked\" name=\"sex\" value=\"男\" style=\"margin-top: 2px\"> 男") ;
                $("#b").html("<input type=\"radio\" name=\"sex\" value=\"女\" style=\"margin-top: 2px\"> 女") ;
            }
            else if (sex =='女'){
                $("#a").html("<input type=\"radio\"  name=\"sex\" value=\"男\" style=\"margin-top: 2px\"> 男") ;
                $("#b").html("<input type=\"radio\" checked=\"checked\" name=\"sex\" value=\"女\" style=\"margin-top: 2px\"> 女") ;
            }
            <!--时间日历-->
            $('#datetimepicker2').datetimepicker({
                format: 'YYYY-MM-DD',
                locale: moment.locale('zh-cn')
            });
            //.打开对话框
            $("#toxiugaimodal").modal("show");

        }
        function doxiugai(){
            //.
            var params = $("#userxiugaiform").serialize();
            //处理表单控件的中文乱码
            params = decodeURIComponent(params,true);

            var state1 = $("#state1").val() ;

            params = params + "&state="+ state1 ;
            $.ajax({
                'type':'post',
                'url':'${pageContext.request.contextPath}/user/update',
                'data':params,
                success:function(data){
                    // alert(data)
                    //关闭对话框
                    $("#toxiugaimodal").modal('hide') ;
                    //友好的提示
                    swal("提示信息", "修改成功!", "success");
                    //重新加载表格
                    $("#usertb").bootstrapTable('load',data) ;

                    var elems = Array.prototype.slice.call(document.querySelectorAll('.abc'));
                    elems.forEach(function(html) {
                        var switchery = new Switchery(html);
                    });


                }
            })
        }

        //删除用户
        function todel() {
            var ids = "";
            var state = "";
            //1.得到要删除的行
            //返回所选的行，当没有选择任何行的时候返回一个空数组。
            var rows = $("#usertb").bootstrapTable("getSelections");
            if (rows.length == 0) {
                swal("提示信息", "请选择要删除的数据!", "info");
            }
            // else if (rows.state==0){
            //     swal("提示信息", "您选中的数据为启用中的用户!", "info");
            // }
            else {
                $.each(rows, function (index, row) {
                    if(row.state==1){
                        state = row.state;
                    }else {
                        ids = ids + row.uid + "-";
                    }
                });
                if (state=="1"){
                    swal("提示信息", "您选中的数据为启用中的用户!", "info");
                }else {
                    swal({
                        title: "您确定要删除这条信息吗",
                        text: "删除后将无法恢复，请谨慎操作！",
                        type: "warning",
                        showCancelButton: true,
                        confirmButtonColor: "#DD6B55",
                        confirmButtonText: "删除",
                        closeOnConfirm: false
                    }, function () {
                        //得到当前页
                        //绑定当前页开始
                        var options = $("#usertb").bootstrapTable('getOptions');
                        //得到当前页
                        var pn = options.pageNumber;
                        $.post("${pageContext.request.contextPath}/user/del", {'ids': ids, 'pn': pn}, function (data) {
                            //友好的提示
                            swal("删除成功！", "您已经永久删除了这条信息。", "success");
                            //刷新表格

                            $("#usertb").bootstrapTable('load', data);
                            var elems = Array.prototype.slice.call(document.querySelectorAll('.abc'));
                            elems.forEach(function(html) {
                                var switchery = new Switchery(html);
                            });
                        })

                    });
                }

            }
        }

        //分配用户角色
        var userinfoid ;
        function tofenpei(uid){
            userinfoid = uid;
            var a = 0 ;
            var s = "" ;
            // <div class="radio-inline">
            //<input type='radio' value=>
            //  <label>管理员</label>
            //</div>
            //打开一个对话框
            $("#fenpei").modal('show') ;
            //当对话框加载完成后，绑定年有角色
            $("#fenpei").on("shown.bs.modal",function(){
              if(++a==1){
                  $.post('${pageContext.request.contextPath}/role/query',{"id":uid},function(data){
                      for (var i=0;i<data.length;i++){
                          var r = data[i] ;
                          var id = r.id ;
                          var rname = r.rname ;
                          var ischecked = r.ischecked ;
                          if (ischecked) {
                              s = s + "<div class='radio-inline'><input  name='js' checked type='radio' value=" + id + "></input><label>" + rname + "</label></div>";
                          }
                          else
                          {
                              s = s + "<div class='radio-inline'><input  name='js'  type='radio' value=" + id + "></input><label>" + rname + "</label></div>";
                          }
                      }
                      $("#juesebody").html(s) ;
                      s="";
                  }) ;
              }
            }) ;

        }
        function dofenpei() {

            //1.得到用户的id，角色的id
            var roleid = $("input[name='js']:checked").val() ;
            // alert(roleid+"++++++"+userinfoid)
            //2.send ajax
            $.post("${pageContext.request.contextPath}/user/fenPei",{"uid":userinfoid,"rid":roleid},function(){
                //关闭对话框,刷新表格
                $("#fenpei").modal('hide') ;
                //   $("#usertb").bootstrapTable('load') ;
            }) ;
        }


    </script>
</head>
<body>
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">用户列表</h3>
    </div>
    <div class="panel-body">
        <div class="row">
            <div class="col-sm-6">
                <button onclick="toadd()" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;增加</button>
                <button onclick="todel()" class="btn btn-primary"><span class="glyphicon glyphicon-trash"></span>&nbsp;&nbsp;删除</button>
            </div>
            <div class="col-sm-6">
                <form  class="form-inline pull-right">
                    <input id="username" type="text" class="form-control">
                    <button class="btn btn-primary" onclick="searcha()" type="button"><span class="glyphicon glyphicon-search"></span>&nbsp;&nbsp;搜索</button>
                </form>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <table id="usertb"></table>
            </div>
        </div>

    </div>
</div>
<!--增加模态框-->
<div  class="modal inmodal" id="addmodal">
    <div class="modal-dialog">
            <div class="modal-content animated bounceInLeft">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">新建员工</h4>
                </div>
                <div class="modal-body" id="addModel">
                    <form class="form-horizontal" id="userform"  method="post" role="form">
                        <input type="hidden" name="pn">
                        <div class="form-group">
                            <label class="col-sm-4 text-right" for="username">用户名</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="uname"  placeholder="用户名" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="upwd" class="col-sm-4 text-right">密码</label>
                            <div class="col-sm-6">
                                <input type="password" class="form-control" name="upwd"  />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="confirmpwd" class="col-sm-4 text-right">确认密码</label>
                            <div class="col-sm-6">
                                <input type="password" class="form-control" name="confirmpwd"  />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="state" class="col-sm-4 text-right">状态</label>
                            <div class="col-sm-6">
                                <input id="state" value="0" type="checkbox" class="js-switch" checked name="state"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="workname" class="col-sm-4 text-right">workName</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="workName"  />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="sex" class="col-sm-4 text-right">性别</label>
                            <div class="col-sm-6">
                                <div class="radio-inline" style="margin-top: -8px">
                                    <input type="radio" name="sex" value="男" style="margin-top: 2px">
                                    男
                                </div>

                                <div class="radio-inline" style="margin-top: -8px">
                                    <input type="radio" name="sex" value="女" style="margin-top: 2px"> 女
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="phone" class="col-sm-4 text-right">手机</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="phone"  />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="borndate" class="col-sm-4 text-right">入职</label>
                            <div class="col-sm-6">
                                <div class="input-group" id="datetimepicker1">
                                    <input name="borndate" type='text' class="form-control" />
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="idCard" class="col-sm-4 text-right">身份证</label>
                            <div class="col-sm-6">
                                <input type="text" id="idCard" class="form-control" name="idCard"  />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="address" class="col-sm-4 text-right">籍贯</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="address" id="address">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                    <button onclick="doadd()" type="button" class="btn btn-primary">保存</button>
                </div>
            </div>
    </div>
</div>
<!--修改模态框-->
<div  class="modal inmodal" id="toxiugaimodal">
    <div class="modal-dialog">
        <form class="form-horizontal" id="userxiugaiform"  method="post" role="form">
            <input type="hidden" name="uid">
            <input type="hidden" name="pn">
            <div class="modal-content animated bounceInLeft">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">修改信息</h4>
                </div>
                <%--<input type="hidden"  name="uid"/>--%>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-4 text-right" for="uname">用户名</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="uname"  placeholder="用户名" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="upwd" class="col-sm-4 text-right">密码</label>
                        <div class="col-sm-6">
                            <input type="password" class="form-control" name="upwd"  />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="state" class="col-sm-4 text-right">状态</label>
                        <div class="col-sm-6" id="state1c">
                            <input  id="state1" type="checkbox" class="js-switch" name="state"  />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="workName" class="col-sm-4 text-right">workName</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="workName"  />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sex" class="col-sm-4 text-right">性别</label>
                        <div class="col-sm-6">
                            <div id="a" class="radio-inline" style="margin-top: -8px">
                                <input type="radio" value="男" name="sex"> 男
                            </div>

                            <div id="b" class="radio-inline" style="margin-top: -8px">
                                <input type="radio" value="女" name="sex"> 女
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="phone" class="col-sm-4 text-right">手机</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="phone"  />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="borndate" class="col-sm-4 text-right">生日：</label>
                        <div class="col-sm-6">
                            <div class="input-group" id="datetimepicker2">
                                <input name="borndate" type='text' class="form-control" />
                                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="address" class="col-sm-4 text-right">籍贯：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="address">
                        </div>
                    </div>
                    <%--<div class="form-group">--%>
                        <%--<label for="idCard" class="col-sm-4 text-right">身份证：</label>--%>
                        <%--<div class="col-sm-6">--%>
                            <%--<input type="text" class="form-control" name="idCard">--%>
                        <%--</div>--%>
                    <%--</div>--%>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                    <button onclick="doxiugai()" type="button" class="btn btn-primary">修改</button>
                </div>

                <script>
                    function smt(){
                        //启用较验
                        $('#userform').data('bootstrapValidator').validate();
                        //验证是否通过true/false
                        var flag = $('#userform').data('bootstrapValidator').isValid() ;
                        if (flag){
                            //序列化表单
                            var formStr=$('#userform').serialize();
                            //处理表单控件的中文乱码
                            params = decodeURIComponent(formStr,true);
                            $.ajax({
                                'type':'post',
                                'url':'${pageContext.request.contextPath}/user/save',
                                'data':params,
                                success:function(data){
                                    //关闭对话框
                                    $("#addmodal").modal('hide') ;
                                    //重新加载表格
                                    $("#usertb").bootstrapTable('load',data) ;
                                }
                            })
                        }


                    }
                </script>
            </div>
        </form>
    </div>
</div>
<!--分配角色的对话框-->
<div class="modal fade" id="fenpei" >
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" >提示信息</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12" id="juesebody">
                        <%--<c:forEach items="${fenPeiList}" var="r">--%>
                            <%--<div class='radio-inline'><input  name='js' checked type='radio' value=" ${r.id}"></input><label>${r.rname}</label></div>--%>
                        <%--</c:forEach>--%>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <button onclick="dofenpei()" type="button" class="btn btn-primary">分配</button>
            </div>
        </div>
    </div>
</div>

</body>
</html>
